import { Request } from '../utils/request';
import { ApiResponse, Comment, PaginationParams, PaginationResult } from '../types';

export class CommentApi {
  constructor(private request: Request) {}

  /**
   * 获取评论列表
   */
  async getComments(postId: number, params: PaginationParams): Promise<ApiResponse<PaginationResult<Comment>>> {
    return this.request.get(`/api/posts/${postId}/comments`, { params });
  }

  /**
   * 创建评论
   */
  async createComment(postId: number, content: string): Promise<ApiResponse<Comment>> {
    return this.request.post(`/api/posts/${postId}/comments`, { content });
  }

  /**
   * 删除评论
   */
  async deleteComment(postId: number, commentId: number): Promise<ApiResponse<void>> {
    return this.request.delete(`/api/posts/${postId}/comments/${commentId}`);
  }

  /**
   * 点赞评论
   */
  async likeComment(postId: number, commentId: number): Promise<ApiResponse<void>> {
    return this.request.post(`/api/posts/${postId}/comments/${commentId}/like`);
  }

  /**
   * 取消点赞评论
   */
  async unlikeComment(postId: number, commentId: number): Promise<ApiResponse<void>> {
    return this.request.delete(`/api/posts/${postId}/comments/${commentId}/like`);
  }
} 